function countSubstrings(s){
    let len = s.length
    let count = 0
   
    for(let center=0; center<len; center++){
         // 奇数
        count += 1
        let left = center - 1 
        let right = center + 1
        while (left >= 0 && right < len && s[left] === s[right]) {
            count += 1
            left -= 1
            right += 1
        }
        console.log(center, count, left, right)
        // 偶数
        let centerL = center
        let centerR = center + 1
        if(s[centerL] === s[centerR]){
            count += 1
            let left2 = centerL - 1
            let right2 = centerR + 1
            while (left2 >= 0 && right2 < len && s[left2] === s[right2]) {
                count += 1
                left2 -= 1
                right2 += 1
            }
        }
        console.log(center, count)
        
    }
}

let s = "aaaaaa"
countSubstrings(s)